package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;


import java.util.List;

/**
 * 菜品管理
 * @className DishMapper
 * @description DishMapper
 * @auth xxk
 * @date 2025/7/3
 */
@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     *
     * @param categoryId
     * @return Integer
     * @description description
     */
    Integer countByCategoryId(@Param("categoryId") Long categoryId);

    /**
     * 新增菜品
     * @param dish
     * @description description
     */
    @AutoFill(value = OperationType.INSERT)
    void insert(Dish dish);

    /**
     * 分页查询
     * @param dishPageQueryDTO
     * @return List<DishVO>
     * @description description
     */
    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 根据id查询
     * @param id
     * @return Integer
     * @description description
     */
    Dish selectById(Long id);

    /**
     * 批量删除
     * @param id
     * @description description
     */
    @Delete("delete from dish where id = #{id}")
    void deleteById(Long id);

    /**
     * 更新菜品
     * @param dish
     * @description description
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);

    /**
     * 根据categoryId查询
     * @param dish
     * @return List<DishVO>
     * @description description
     */
    List<Dish> list(Dish dish);

    /**
     * 根据套餐id查询关联到的所有菜品
     * @param id
     * @return List<Dish>
     * @description description
     */
    List<Dish> selectBySetmealId(Long id);

    List<DishVO> selectByCategoryId(@Param("categoryId")Long categoryId);

}
